<%@ page language="java" import="java.util.*, com.zjut.zs.util.tools.*,com.zjut.an.config.manager.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="edge" />
    <title>网站登录</title>
    
	<link rel="stylesheet" type="text/css" href="../plugins/layuiadmin/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="css/adminlogin.css" media="all">
<script type="text/javascript">
console.info(window.location.port);
//if("80"!=window.location.port) {
//	alert(window.location.port+"访问路径不允许");
    //window.location.href = "../apply/main.jsp";
//}

var browser=navigator.appName
var b_version=navigator.appVersion
var version=b_version.split(";");
var trim_Version=version[1].replace(/[ ]/g,"");
if(browser=="Microsoft Internet Explorer" && (trim_Version=="MSIE7.0"||trim_Version=="MSIE6.0"))
{
    var returnVal = window.confirm("您的浏览器版本过低或者开启了兼容模式，无法使用本系统，点击确定跳转到帮助页面查阅登录方法", "标题");
    if(returnVal) {
    	window.location.href = "soft.html";
	} else {
		window.location.href = "AdminLogin.html";
	}
}
</script>  
<script type="text/javascript" src="../plugins/assets/plugins/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="js/util.js"></script>
</head>
<%
AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
%>
<body>
    <div id="login_bg" class ="login_bg" style="background-image:url(images/bg2.jpg);"></div>
    <div class="login_header">
    	<span></span>
    </div>
    <div class="container">
    	<div class="form_header">
        	<h1 id="logo">浙江省高校</br>三位一体综合评价招生系统V4.1</h1>
			<h2 id="subheading">版权所有@ 杭州智栖科技有限公司 - </h2>
        </div>
<div class="layui-tab layui-tab-card">
  <ul class="layui-tab-title">
    <li class="layui-this">系统管理员登录</li>
    <li>专家评审登录</li>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show signup_forms">

<div id="login1">
<form id="form1" action="" method="post" onsubmit="return adminlogin1();">
<table border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td>身份</td>
    <td>
    <select id="roId" name="roId">
    </select>
    </td>
  </tr>
  <tr>
    <td width="80">账号</td>
    <td>
    <input type="text" name="account" id="account"></td>
  </tr>
  <tr>
    <td>密码</td>
    <td><input type="password" name="password" id="password" autocomplete="off"></td>
  </tr>
  <%if("是".equals(anconfig.getSingleConfigInfoByName("管理登录是否启用短信验证码"))) {%>
	  <tr>
	    <td>手机</td>
	    <td><input id="usMobile" name="usMobile" type="text" class="dfinput" placeholder="账号关联手机号" onkeyup="this.value=this.value.replace(/\D/g,'')" onblur="checkmobile()"/>
		<i id="mobilelabel"></i></td>
	  </tr>
	  <tr>
	    <td>验证码</td>
	    <td>
	    <input type="text" id="code" name="code" placeholder="短信验证码"  class="dfinput" onblur="checkcode()" required/>
	    <button type="button" id="hqyzm" class="signup_forms_button" onclick="getcode()">
			<span>点击获取验证码</span>
		</button><i id="codelabel"></i></td>
	  </tr>
  <%}else{ %>
  	<tr>
	    <td>验证码</td>
	    <td><input type="text" name="rand" id="rand" style="width:100px;"><img style="cursor:pointer;width:60px;height:26px;float:left;margin:5px;" alt="" onclick="changeValidateCode()" ver_colorofnoisepoint="#888888" id="JD_Verification1" src="../getValidateImage.action"></td>
  	</tr>
  <%} %>
  <tr>
    <td>&nbsp;</td>
    <td><button type="submit" id="signup_forms_submit"><span><strong>登录</strong></span></button></td>
  </tr>
</table>
</form>
</div>

	</div>
    <div class="layui-tab-item signup_forms">

<div id="login2">
<form id="form2" action="" method="post" onsubmit="return adminlogin2();">
<table  border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td width="60">账号</td>
    <td>
    <input type="text" name="account" id="account2"></td>
  </tr>
  <tr>
    <td>密码</td>
    <td><input type="password" name="password" id="password2" autocomplete="off"></td>
  </tr>
  <tr>
    <td>验证码</td>
    <td><input type="text" name="rand" id="rand2" style="width:100px;"><img style="cursor:pointer;width:60px;height:26px;float:left;margin:5px;" alt="" onclick="changeValidateCode()" ver_colorofnoisepoint="#888888"   id="JD_Verification1" src="../getValidateImage.action"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    <input type="text" name="roId" class="layui-input" value="0" style="display:none;">
    <button type="submit" id="signup_forms_submit"><span><strong>登录</strong></span></button></td>
  </tr>
</table>
</form>
</div>

	</div>
  </div>
</div>


        <div class="signup_forms" class="signup_forms">
            	
            <div class="footer">
		    	<div class="footer_signup_link">
		        	<a class="signup_link" href="soft.html" target='_blank' id="message">账号密码正确却无法登录，请点击此处</a>
		        </div>
	    	</div>
    	</div>

<script type="text/javascript" src="../plugins/layuiadmin/layui/layui.js"></script>
<script>
//注意：选项卡 依赖 element 模块，否则无法进行功能性操作
layui.use('element', function(){
  var element = layui.element;
 
  //…
});
</script>	
<script type="text/javascript">  

$.ajax({
    type : "post",
    url : "../anRoleList.action?randnum=", 
    success : function(res, status) {
    	console.info(res);
        $.each(res.rows, function(index, item) {
            $("#roId").append(  //此处向select中循环绑定数据
        	"<option value="+item.roId+">" + item.roName+ "</option>");
        });	
	},
});
		
$.ajaxSetup({ cache: false }); 

function adminlogin1() {
	var actionurl='../anAdminLogin.action?randnum='+Math.floor(Math.random()*1000000);

	if ($("#account").val() == "") {
		$("#message").html("登陆账号必须填写！");
	} else if ($("#password").val() == "") {
		$("#message").html("登陆密码必须填写！");
	} else if ($("#code").val() == "") {
		$("#message").html("验证码必须填写！");
	} else {
		var jsonString = $("#form1").form2json();
		//console.info(jsonString);
		$.ajax({
	    	cache: false,
	    	type: "POST",
	        url:actionurl,
	        data:{rowstr:jsonString},// 你的formid
	        async: false,
	        dataType: 'json',
	        error: function(request) {
	        	alert("网络错误，无法连接到服务器。");
	        },
	        success: function(data) {
	        	console.log(data);
	        	var roId = $("#roId").val();
	        	if(data.message=="success"){
	            	alert("登录成功");
	            	window.location = './index.jsp'; ///当用ajax访问 时候成功的时候就自动的跳转过去
	        	} else if(data.message=="sqmfailed"){
	            	$("#message").html("登录失败，系统授权码错误！");
	        		alert("登录失败，系统授权码错误！");
	        	} else if(data.message=="randfailed"){
	            	$("#message").html("登录失败，验证码错误！");
	        		alert("登录失败，验证码错误！");
	        	} else if(data.message=="timefailed"){
	            	$("#message").html("密码错误或者身份设置有误超过5次，请于30秒稍后再试！");
	        		alert("密码错误或者身份设置有误超过5次，请于30秒稍后再试！");
	        	} else {
	        		$("#message").html("登录失败，用户名或密码错误或者身份设置有误！");
	        		alert("登录失败，用户名或密码错误或者身份设置有误！");
	        	}
	        }
	    });
	}
	return false;
}

var mobilecheck=0;
var codecheck=0;
var code;
function checkmobile() {
	var mobile = $("#usMobile").val();
	var label = document.getElementById("mobilelabel");
	var phone = /^1\d{10}$/;
	if (phone.test(mobile)) {
		$.ajax({
			async:false,
			cache:false,
			url: "../anAdminCount.action?mobile=" + mobile,
			type: "GET",
			dataType: "json",
		
			success: function(data) {
				console.info(data);
				if (parseInt(data.total) > 0) {
					mobilecheck=1;
				} else {
					$("#mobilelabel").css("color","red");
					$("#mobilelabel").html("手机号码错误");
					mobilecheck=0;
				}
			},
			error: function(xhr, type, errorThrown) {},
			complete: function(xhr, type, errorThrown) {}
		});
	} else {
		$("#mobilelabel").css("color","red");
		if (mobile == "") $("#mobilelabel").html("请输入手机号码");
		else $("#mobilelabel").html("请输入正确的手机号码");
	}
}
function getcode() {
	//alert(idcardcheck);
	//alert((idcardcheck == 1));
	//alert((mobilecheck == 1));
	//alert((idcardcheck == 1) && (mobilecheck == 1));
	if (mobilecheck == 1) {
		var mobile = $("#usMobile").val();
		//alert( $("#usMobile").val());
		$.ajax({
			async:false,
			cache:false,
			url: "../sendSMS.action?usMobile=" + mobile,
			type: "GET",
			dataType: "json",
			success: function(data) {
			    //alert(data);
				//code = data.code;
				var count = 60;
				if (data.flag == "timeerror") {
					$("#codelabel").html("发送太频繁了，请稍等");
				} else if (data.flag == "success") {
					var yz = document.getElementById("hqyzm");
					yz.disabled = true;
					var timer = setInterval(function() {
						
						$("#hqyzm").html(count + "秒");
						count--;
						if (count == 0) {
							clearInterval(timer);
							$("#hqyzm").html("获取验证码");
							yz.disabled = false;
						}
					}, "1000");
				}
			},
			error: function(xhr, type, errorThrown) {},
			complete: function(xhr, type, errorThrown) {}
		});
	} else {
		checkmobile();
	}
}

function checkcode() {
	var temp = document.getElementById("code").value;
	var label = document.getElementById("codelabel");
	console.info(code);
	console.info(temp);
	if (temp == ""){
		$("#message").html("请填写验证码");
		codecheck=0;
	} else {
		$.ajax({
			async:false,
			cache:false,
			url: "../checkCode.action?code=" + temp,
			type: "GET",
			dataType: "json",
		
			success: function(data) {
				if(data.message=="success"){
					$("#codelabel").css("color","green");
					$("#codelabel").html("验证码正确");
					codecheck=1;
					$("#usPassword").removeAttr("disabled");
					$("#usPassword2").removeAttr("disabled");
	        	} else {
	        		$("#codelabel").css("color","red");
	    			$("#codelabel").html("验证码错误");
	    			$("#message").html("验证码错误");
	    			codecheck=0;
	        	}
			},
			error: function(xhr, type, errorThrown) {},
			complete: function(xhr, type, errorThrown) {}
		});
	}
}

function adminlogin2() {
	var actionurl='../anUserLogin.action?randnum='+Math.floor(Math.random()*1000000);

	if ($("#account2").val() == "") {
		$("#message").html("登陆账号必须填写！");
	} else if ($("#password2").val() == "") {
		$("#message").html("登陆密码必须填写！");
	} else if ($("#rand2").val() == "") {
		$("#message").html("验证码必须填写！");
	} else {
		var jsonString = $("#form2").form2json();
		//console.info(jsonString);
		$.ajax({
	    	cache: false,
	    	type: "POST",
	        url:actionurl,
	        data:{rowstr:jsonString},// 你的formid
	        async: false,
	        dataType: 'json',
	        error: function(request) {
	        	alert("网络错误，无法连接到服务器。");
	        },
	        success: function(data) {
	        	console.log(data);
	        	var roId = $("#roId").val();
	        	if(data.message=="success"){
	            	alert("登录成功");
	            	window.location = './index_review.jsp'; ///当用ajax访问 时候成功的时候就自动的跳转过去
	        	} else if(data.message=="sqmfailed"){
	            	$("#message").html("登录失败，系统授权码错误！");
	        		alert("登录失败，系统授权码错误！");
	        		changeValidateCode();
	        	} else if(data.message=="randfailed"){
	            	$("#message").html("登录失败，验证码错误！");
	        		alert("登录失败，验证码错误！");
	        		changeValidateCode();
	        	} else if(data.message=="timefailed"){
	            	$("#message").html("密码错误或者身份设置有误超过5次，请于30秒稍后再试！");
	        		alert("密码错误或者身份设置有误超过5次，请于30秒稍后再试！");
	        		changeValidateCode();
	        	} else {
	        		$("#message").html("登录失败，用户名或密码错误或者身份设置有误！");
	        		alert("登录失败，用户名或密码错误或者身份设置有误！");
	        		changeValidateCode();
	        	}
	        }
	    });
	}
	return false;
}

function changeValidateCode() {    
      //这和浏览器的缓存机制有关系，也可以把页面设置为不缓存，这样就不用这个参数了。"nocache="+new Date().getTime()   
      document.getElementById("JD_Verification1").src=document.getElementById("JD_Verification1").src + "?nocache="+new Date().getTime();    
}   
	</script>
</body>
</html>